package com.rzjm.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rzjm.api.dao.*;
import com.rzjm.api.entity.*;
import com.rzjm.api.service.SplitAccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 分成账户Service业务层处理
 *
 * @author ruoyi
 * @date 2021-09-08
 */
@Service
public class SplitAccountServiceImpl extends BaseServiceImpl<SplitAccountMapper, SplitAccount> implements SplitAccountService {

    @Resource
    private SplitAccountMapper splitAccountMapper;

    /**
     * 账户类型  0 - 平台   1 - 物业  2 -  小区  3 - 商家   4 - 个人
     * @param userId
     * @param accountType
     * @return
     */
    @Override
    public SplitAccount getAccountByUserId(int userId, int accountType, int accountId) {
        QueryWrapper<SplitAccount> qw = new QueryWrapper<>();
        qw.eq("user_id",userId);
        qw.eq("account_type",accountType);
        qw.eq("account_id",accountId);
        qw.last("limit 1");
        return splitAccountMapper.selectOne(qw);
    }
}
